package com.manager.service.serviceConfig.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
;
import com.manager.model.Level;
import com.manager.service.serviceConfig.mapper.LevelMapper;
import com.manager.service.serviceConfig.service.LevelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
* @author pooh
* @description 针对表【level】的数据库操作Service实现
* @createDate 2023-03-19 12:45:43
*/
@Service
public class LevelServiceImpl extends ServiceImpl<LevelMapper, Level>
    implements LevelService {
    @Autowired
    LevelMapper levelMapper;

    @Override
    public boolean addLevel(String content) {
        Level level = levelMapper.searchByLevel(content);
        if(level == null){
            Level level1 = new Level();
            level1.setLevel(content);
            level1.setStatus(1);
            this.save(level1);
        }else{
            if(level.getStatus() == 0){
                level.setStatus(1);
                this.updateById(level);
            }else{
                return false;
            }
        }
        return true;
    }
}




